package ideamaps.utils.html;

import com.taillive.commons.ConvertUtils;

public class HtmlTag {
	
	private StringBuffer sb = new StringBuffer();
	
	private String name;
	private String value;
	
	
	private void init(String name,String value){
		this.name = name;
		this.value = value;
		sb.append("<").append(name);
		
	}
	
	public HtmlTag(String name,int value){
		init(name, ConvertUtils.i2s(value));
	}
	public HtmlTag(String name,long value){
		init(name, ConvertUtils.l2s(value));
	}
	public HtmlTag(String name,String value){
		init(name, value);
	}
	
	public HtmlTag add(String attr,String value){
		sb.append(HtmlUtils.attr(attr, value));
		return this;
	}
	
	
	public String toString(){
		if("img".equals(name)){
			return sb.append(HtmlUtils.attr("src", value)).append(">").toString();
		}else{
			return sb.append(">").append(value).append("</").append(name).append(">").toString();
		}
		
		
	}
	
	
}
